package com.tea.controller.user;

import com.tea.dto.GetCouponDTO;
import com.tea.result.Result;
import com.tea.service.UserCouponService;
import com.tea.service.impl.UserCouponServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user/Coupon")
@Slf4j
@Api(tags = "用户端优惠券接口")
public class UserCouponController {

    @Autowired
    UserCouponService userCouponService;

    @PostMapping("/add")
    @ApiOperation("领取优惠券接口")
    public Result add(@RequestBody GetCouponDTO getCouponDTO){
        log.info("前端发送的GetCouponDTO为{}",getCouponDTO);
        userCouponService.distributeCoupon(getCouponDTO);
        return Result.success();
    }
}
